package com.foreveredu.propms.persist.hibernate;

import java.util.List;

import com.foreveredu.propms.domain.Account;
import com.foreveredu.propms.domain.Bill;
import com.foreveredu.propms.domain.Owner;
import com.foreveredu.propms.persist.IAccountDao;


public class HibernateAccountDao extends HibernateAbstractDao<Account, Integer>
		implements IAccountDao {

	private static final long serialVersionUID = 1L;

	public HibernateAccountDao() {
		super(Account.class);
	}

	@SuppressWarnings("unchecked")
	@Override
	public Account findByOwner(Owner owner) {
		String hql = "from Account a where a.owner.id=?";
		List<Account> accountList = this.getHibernateTemplate().find(hql, owner.getId());
		Account account = null;
		if (accountList != null && accountList.size()>0) {
			account = accountList.get(0);
		}
		return account;
	}

}
